package com.yaorange.certificate.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yaorange.common.annotation.Log;
import com.yaorange.common.core.controller.BaseController;
import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.common.enums.BusinessType;
import com.yaorange.certificate.domain.YtjPos;
import com.yaorange.certificate.service.IYtjPosService;
import com.yaorange.common.core.page.TableDataInfo;

/**
 * 一体机服务点Controller
 */
@RestController
@RequestMapping("/system/ytjpos")
public class YtjPosController extends BaseController {
    @Autowired
    private IYtjPosService ytjPosService;

    /**
     * 查询一体机服务点列表
     */
    @PreAuthorize("@ss.hasPermi('system:ytjpos:list')")
    @GetMapping("/list")
    public TableDataInfo list(YtjPos ytjPos) {
        startPage();
        List<YtjPos> list = ytjPosService.selectYtjPosList(ytjPos);
        return getDataTable(list);
    }

    /**
     * 获取一体机服务点详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ytjpos:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ytjPosService.selectYtjPosById(id));
    }

    /**
     * 新增一体机服务点
     */
    @PreAuthorize("@ss.hasPermi('system:ytjpos:add')")
    @Log(title = "一体机服务点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YtjPos ytjPos) {
        return toAjax(ytjPosService.insertYtjPos(ytjPos));
    }

    /**
     * 修改一体机服务点
     */
    @PreAuthorize("@ss.hasPermi('system:ytjpos:edit')")
    @Log(title = "一体机服务点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YtjPos ytjPos) {
        return toAjax(ytjPosService.updateYtjPos(ytjPos));
    }

    /**
     * 删除一体机服务点
     */
    @PreAuthorize("@ss.hasPermi('system:ytjpos:remove')")
    @Log(title = "一体机服务点", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ytjPosService.deleteYtjPosByIds(ids));
    }
}